<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" :close-on-click-modal="false" class="tl-dialog" width="1000px" @open="open" @close="close">
    <el-form class="tl-form" ref="form" :model="model" :rules="rules" label-width="120px" :disabled="disableEditSubmit">
			<el-row>
				<el-col :span="12">
					<el-form-item label="上级类型" prop="parentid">
						<el-input v-model="model.dispparentid" :disabled="true"  class="tl-ref-selector">
								<el-button slot="append" type="primary" icon="el-icon-search" @click="openMeetTypeRefDialog" v-if="!disableEditSubmit"></el-button>
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="名称" prop="name" :rules="rules.validateRequire">
						<el-input v-model="model.name"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="12">
					<el-form-item label="地理类型" prop="geographytype" :rules="rules.validateRequire">
						<el-select v-model="model.geographytype" filterable clearable>
							<el-option v-for="item in codeModel.geographytypeList" :key="item.code" :label="item.name" :value="item.code" />
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="级别类型" prop="gradetype" :rules="rules.validateRequire">
						<el-select v-model="model.gradetype" filterable clearable>
							<el-option v-for="item in codeModel.gradetypeList" :key="item.code" :label="item.name" :value="item.code" />
						</el-select>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="24">
					<el-form-item label="备注" prop="description">
						<el-input v-model="model.description" type="textarea" :rows="4"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="12">
					<el-form-item label="排序码" prop="sortcode">
						<el-input-number v-model="model.sortcode" controls-position="right" :step="1" :min="0" style="width:100%"></el-input-number>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="有效" prop="enabled">
						<el-radio-group v-model="model.enabled">
							<el-radio :label="parseInt(item.code)" v-for="item in codeModel.enabledList" :key="item.code">{{ item.name }}</el-radio>
						</el-radio-group>
					</el-form-item>
				</el-col>
			</el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :type="disableEditSubmit === false ? 'text' : 'primary'" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doSubmitEdit" :loading="saveLoading" v-if="disableEditSubmit === false">确认</el-button>
    </div>
		<tlmeet-type-ref ref="meetTypeRef" @confirm="getMeetTypeRefData" :isSingleSelect="true"></tlmeet-type-ref>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_edit } from '@tapui/mixins/mixin_edit'
/** 子组件 */
import tlmeetTypeRef from '../meetTypeManage/refList'
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
/** VUE配置 */
export default {
  mixins: [mixin_edit],
  components: { tlmeetTypeRef },
  data() {
    return {
      moduleTitle: '会议类型',
      urlPrefix: '/meet/typeManage/',
      url: {
        // 额外的url
      }
    }
  },
  methods: {
    loaded() {
      // 页面加载完毕执行
		},
		// 提交请求之前执行，初始化创建人信息
		beforeSubmit() {
			if (this.isAdd) {
				this.$set(this.model, 'usercode', this.$store.getters.user.code)
				this.$set(this.model, 'username', this.$store.getters.user.name)
			}
      return true
    },
		/** 打开上级类型id参照 */
		openMeetTypeRefDialog() {
			this.$refs.meetTypeRef.visible = true
			// 只允许选择一级节点
			this.$refs.meetTypeRef.externalQueryParam = { qry_parentid: 0 }
			this.$refs.meetTypeRef.selectedRowKeys = []
			this.$refs.meetTypeRef.selectedRowKeys.push(this.model.parentid)
		},
		/** 获取上级类型id参数数据 */
		getMeetTypeRefData(selectionRow, selectKey, selectionValue) {
			this.$set(this.model, 'parentid', selectionRow.id)
			this.$set(this.model, 'dispparentid', selectionRow.name)
		}
  }
}
</script>

